﻿import QtQuick 2.12
import QtQuick.Layouts 1.13
import QtQuick.Controls 2.5



// 本地蓝牙信息窗口
Dialog {
    //id: dialogLocalBluetooth
    //x: parent.width / 2 - width / 2
    //y: parent.height / 2 - height / 2
    anchors.centerIn: parent
    focus: true
    modal: true
    title: qsTr("本地蓝牙信息")
    standardButtons: Dialog.Ok

    function setInfo(bluetoothInfo)
    {
        localBluetoothName.text = bluetoothInfo.deviceName;
        localBluetoothAddr.text = bluetoothInfo.deviceAddr;
        if(!bluetoothInfo.isValid)
        {
            localBluetoothStatus.text = qsTr("无效");
        }
        else
        {
            localBluetoothStatus.text = bluetoothInfo.hostMode;
        }
        localBluetoothConnectedCound.text = bluetoothInfo.connectedDevicesCount;
    }

    contentItem: Item {
        GridLayout {
            id: grid
            property int minimumInputSize: 120
            columns: 2

            Label {
                text: qsTr("名称")
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
            }
            TextField {
                id: localBluetoothName
                focus: true
                Layout.fillWidth: true
                Layout.minimumWidth: grid.minimumInputSize
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
                readOnly: true
            }
            Label {
                text: qsTr("地址")
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
            }
            TextField {
                id: localBluetoothAddr
                Layout.fillWidth: true
                Layout.minimumWidth: grid.minimumInputSize
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
                readOnly: true
            }
            Label {
                text: qsTr("状态")
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
            }
            TextField {
                id: localBluetoothStatus
                Layout.fillWidth: true
                Layout.minimumWidth: grid.minimumInputSize
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
                readOnly: true
            }
            Label {
                text: qsTr("连接数");
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
            }
            TextField {
                id: localBluetoothConnectedCound
                Layout.fillWidth: true
                Layout.minimumWidth: grid.minimumInputSize
                Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
                readOnly: true
            }
        }
    }
    //onAccepted: finished(form.fullName.text, form.address.text, form.city.text, form.number.text)
}
